﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcps.Web.supplierinfo
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtsupplyname.Text.Trim().Length==0)
			{
				strErr+="supplyname不能为空！\\n";	
			}
			if(this.txtsuppliername.Text.Trim().Length==0)
			{
				strErr+="suppliername不能为空！\\n";	
			}
			if(this.txtsupplierphone.Text.Trim().Length==0)
			{
				strErr+="supplierphone不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string supplyname=this.txtsupplyname.Text;
			string suppliername=this.txtsuppliername.Text;
			string supplierphone=this.txtsupplierphone.Text;

			lcps.Model.supplierinfo model=new lcps.Model.supplierinfo();
			model.supplyname=supplyname.Trim();
			model.suppliername=suppliername.Trim();
			model.supplierphone=supplierphone.Trim();

			lcps.BLL.supplierinfo bll=new lcps.BLL.supplierinfo();
            if (bll.GetList(" supplyname='" + supplyname + "'").Tables[0].Rows.Count == 0)
            {
                bll.Add(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");

            }
            else
            {
                Maticsoft.Common.MessageBox.Show(this, "供应商已存在！");
            

            }
			

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
